# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=roc-toolkit
pkgver=0.2.3
pkgrel=1
pkgdesc="Real-time audio streaming over the network"
arch=(loong64 x86_64)
url="https://github.com/roc-streaming/roc-toolkit/"
license=(MPL2 custom:CC0)
depends=(
  glibc
  libunwind
  libuv
)
makedepends=(
  alsa-lib
  cpputest
  gengetopt
  libpulse
  openfec
  ragel
  scons
  sox
  speexdsp
)
optdepends=(
  'libpulse: for roc-conv, roc-receive and roc-send'
  'sox: for roc-conv, roc-receive and roc-send'
)
provides=(libroc.so)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('f57b76cf6e5bda00072008b17c13fb9e5ae74e6fd6c141da10a2395d4b1ea150f1353081937afe7493af7e7e4d4db1bae87cd4cdea073fa9c138c9c5ada0d90a')
b2sums=('cd75f33feacdab77fdfadea87d8e72a39a2cf7ef423450c511eb39e1506055ca6db7d38f378aaa7500d9d4bfb4c6b2111a9b4f43800f87c7e1fe559bcb522711')

build() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --disable-openssl  # disable as it is not yet used
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons "${scons_options[@]}"
}

check() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --disable-openssl  # disable as it is not yet used
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons test "${scons_options[@]}"
}

package() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
  )
  depends+=(
    openfec libopenfec.so
    speexdsp libspeexdsp.so
  )

  cd $pkgname-$pkgver
  scons DESTDIR="$pkgdir/" "${scons_options[@]}" install

  install -vDm 644 3rdparty/hedley/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/hedley.COPYING"
}
